package logic

import (
	"card/app/response"
	"card/pkg/captcha"
	"github.com/gin-gonic/gin"
)

type Captcha struct {
	ctx *gin.Context
}

func NewCaptcha(ctx *gin.Context) *Captcha {
	return &Captcha{ctx: ctx}
}

func (l *Captcha) GetImage() (*response.Captcha, error) {
	id, b64s, _, err := captcha.NewCaptcha().GenerateCaptcha()
	if err != nil {
		return nil, err
	}
	return &response.Captcha{
		Id:    id,
		Image: b64s,
	}, nil
}
